// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.


suite("test_cast_to_largeint_from_datetimev2_0_part6") {

    // This test case is generated from the correspoinding be UT test case,
    // update this case if the correspoinding be UT test case is updated,
    // e.g.: ../run-be-ut.sh --run --filter=FunctionCastToDecimalTest.* --gen_regression_case
    sql "drop table if exists test_cast_to_largeint_from_datetimev2_0_part6_6_nullable;"
    sql "create table test_cast_to_largeint_from_datetimev2_0_part6_6_nullable(f1 int, f2 datetimev2(0)) properties('replication_num'='1');"
    sql """insert into test_cast_to_largeint_from_datetimev2_0_part6_6_nullable values (0, "0100-12-01 01:01:00"),(1, "0100-12-01 01:01:00"),(2, "0100-12-01 01:01:00"),(3, "0100-12-01 01:01:01"),(4, "0100-12-01 01:01:01"),(5, "0100-12-01 01:01:01"),(6, "0100-12-01 01:01:59"),(7, "0100-12-01 01:01:59"),(8, "0100-12-01 01:01:59"),(9, "0100-12-01 01:59:00"),(10, "0100-12-01 01:59:00"),(11, "0100-12-01 01:59:00"),(12, "0100-12-01 01:59:01"),(13, "0100-12-01 01:59:01"),(14, "0100-12-01 01:59:01"),(15, "0100-12-01 01:59:59"),(16, "0100-12-01 01:59:59"),(17, "0100-12-01 01:59:59"),(18, "0100-12-01 23:00:00"),(19, "0100-12-01 23:00:00"),
      (20, "0100-12-01 23:00:00"),(21, "0100-12-01 23:00:01"),(22, "0100-12-01 23:00:01"),(23, "0100-12-01 23:00:01"),(24, "0100-12-01 23:00:59"),(25, "0100-12-01 23:00:59"),(26, "0100-12-01 23:00:59"),(27, "0100-12-01 23:01:00"),(28, "0100-12-01 23:01:00"),(29, "0100-12-01 23:01:00"),(30, "0100-12-01 23:01:01"),(31, "0100-12-01 23:01:01"),(32, "0100-12-01 23:01:01"),(33, "0100-12-01 23:01:59"),(34, "0100-12-01 23:01:59"),(35, "0100-12-01 23:01:59"),(36, "0100-12-01 23:59:00"),(37, "0100-12-01 23:59:00"),(38, "0100-12-01 23:59:00"),(39, "0100-12-01 23:59:01"),
      (40, "0100-12-01 23:59:01"),(41, "0100-12-01 23:59:01"),(42, "0100-12-01 23:59:59"),(43, "0100-12-01 23:59:59"),(44, "0100-12-01 23:59:59"),(45, "0100-12-28 00:00:00"),(46, "0100-12-28 00:00:00"),(47, "0100-12-28 00:00:00"),(48, "0100-12-28 00:00:01"),(49, "0100-12-28 00:00:01"),(50, "0100-12-28 00:00:01"),(51, "0100-12-28 00:00:59"),(52, "0100-12-28 00:00:59"),(53, "0100-12-28 00:00:59"),(54, "0100-12-28 00:01:00"),(55, "0100-12-28 00:01:00"),(56, "0100-12-28 00:01:00"),(57, "0100-12-28 00:01:01"),(58, "0100-12-28 00:01:01"),(59, "0100-12-28 00:01:01"),
      (60, "0100-12-28 00:01:59"),(61, "0100-12-28 00:01:59"),(62, "0100-12-28 00:01:59"),(63, "0100-12-28 00:59:00"),(64, "0100-12-28 00:59:00"),(65, "0100-12-28 00:59:00"),(66, "0100-12-28 00:59:01"),(67, "0100-12-28 00:59:01"),(68, "0100-12-28 00:59:01"),(69, "0100-12-28 00:59:59"),(70, "0100-12-28 00:59:59"),(71, "0100-12-28 00:59:59"),(72, "0100-12-28 01:00:00"),(73, "0100-12-28 01:00:00"),(74, "0100-12-28 01:00:00"),(75, "0100-12-28 01:00:01"),(76, "0100-12-28 01:00:01"),(77, "0100-12-28 01:00:01"),(78, "0100-12-28 01:00:59"),(79, "0100-12-28 01:00:59"),
      (80, "0100-12-28 01:00:59"),(81, "0100-12-28 01:01:00"),(82, "0100-12-28 01:01:00"),(83, "0100-12-28 01:01:00"),(84, "0100-12-28 01:01:01"),(85, "0100-12-28 01:01:01"),(86, "0100-12-28 01:01:01"),(87, "0100-12-28 01:01:59"),(88, "0100-12-28 01:01:59"),(89, "0100-12-28 01:01:59"),(90, "0100-12-28 01:59:00"),(91, "0100-12-28 01:59:00"),(92, "0100-12-28 01:59:00"),(93, "0100-12-28 01:59:01"),(94, "0100-12-28 01:59:01"),(95, "0100-12-28 01:59:01"),(96, "0100-12-28 01:59:59"),(97, "0100-12-28 01:59:59"),(98, "0100-12-28 01:59:59"),(99, "0100-12-28 23:00:00"),
      (100, "0100-12-28 23:00:00"),(101, "0100-12-28 23:00:00"),(102, "0100-12-28 23:00:01"),(103, "0100-12-28 23:00:01"),(104, "0100-12-28 23:00:01"),(105, "0100-12-28 23:00:59"),(106, "0100-12-28 23:00:59"),(107, "0100-12-28 23:00:59"),(108, "0100-12-28 23:01:00"),(109, "0100-12-28 23:01:00"),(110, "0100-12-28 23:01:00"),(111, "0100-12-28 23:01:01"),(112, "0100-12-28 23:01:01"),(113, "0100-12-28 23:01:01"),(114, "0100-12-28 23:01:59"),(115, "0100-12-28 23:01:59"),(116, "0100-12-28 23:01:59"),(117, "0100-12-28 23:59:00"),(118, "0100-12-28 23:59:00"),(119, "0100-12-28 23:59:00"),
      (120, "0100-12-28 23:59:01"),(121, "0100-12-28 23:59:01"),(122, "0100-12-28 23:59:01"),(123, "0100-12-28 23:59:59"),(124, "0100-12-28 23:59:59"),(125, "0100-12-28 23:59:59"),(126, "2025-01-01 00:00:00"),(127, "2025-01-01 00:00:00"),(128, "2025-01-01 00:00:00"),(129, "2025-01-01 00:00:01"),(130, "2025-01-01 00:00:01"),(131, "2025-01-01 00:00:01"),(132, "2025-01-01 00:00:59"),(133, "2025-01-01 00:00:59"),(134, "2025-01-01 00:00:59"),(135, "2025-01-01 00:01:00"),(136, "2025-01-01 00:01:00"),(137, "2025-01-01 00:01:00"),(138, "2025-01-01 00:01:01"),(139, "2025-01-01 00:01:01"),
      (140, "2025-01-01 00:01:01"),(141, "2025-01-01 00:01:59"),(142, "2025-01-01 00:01:59"),(143, "2025-01-01 00:01:59"),(144, "2025-01-01 00:59:00"),(145, "2025-01-01 00:59:00"),(146, "2025-01-01 00:59:00"),(147, "2025-01-01 00:59:01"),(148, "2025-01-01 00:59:01"),(149, "2025-01-01 00:59:01"),(150, "2025-01-01 00:59:59"),(151, "2025-01-01 00:59:59"),(152, "2025-01-01 00:59:59"),(153, "2025-01-01 01:00:00"),(154, "2025-01-01 01:00:00"),(155, "2025-01-01 01:00:00"),(156, "2025-01-01 01:00:01"),(157, "2025-01-01 01:00:01"),(158, "2025-01-01 01:00:01"),(159, "2025-01-01 01:00:59"),
      (160, "2025-01-01 01:00:59"),(161, "2025-01-01 01:00:59"),(162, "2025-01-01 01:01:00"),(163, "2025-01-01 01:01:00"),(164, "2025-01-01 01:01:00"),(165, "2025-01-01 01:01:01"),(166, "2025-01-01 01:01:01"),(167, "2025-01-01 01:01:01"),(168, "2025-01-01 01:01:59"),(169, "2025-01-01 01:01:59"),(170, "2025-01-01 01:01:59"),(171, "2025-01-01 01:59:00"),(172, "2025-01-01 01:59:00"),(173, "2025-01-01 01:59:00"),(174, "2025-01-01 01:59:01"),(175, "2025-01-01 01:59:01"),(176, "2025-01-01 01:59:01"),(177, "2025-01-01 01:59:59"),(178, "2025-01-01 01:59:59"),(179, "2025-01-01 01:59:59"),
      (180, "2025-01-01 23:00:00"),(181, "2025-01-01 23:00:00"),(182, "2025-01-01 23:00:00"),(183, "2025-01-01 23:00:01"),(184, "2025-01-01 23:00:01"),(185, "2025-01-01 23:00:01"),(186, "2025-01-01 23:00:59"),(187, "2025-01-01 23:00:59"),(188, "2025-01-01 23:00:59"),(189, "2025-01-01 23:01:00"),(190, "2025-01-01 23:01:00"),(191, "2025-01-01 23:01:00"),(192, "2025-01-01 23:01:01"),(193, "2025-01-01 23:01:01"),(194, "2025-01-01 23:01:01")
      ,(195, null);
    """

    sql "set enable_strict_cast=true;"
    qt_sql_6_strict 'select f1, cast(f2 as largeint) from test_cast_to_largeint_from_datetimev2_0_part6_6_nullable order by 1;'

    sql "set enable_strict_cast=false;"
    qt_sql_6_non_strict 'select f1, cast(f2 as largeint) from test_cast_to_largeint_from_datetimev2_0_part6_6_nullable order by 1;'

    sql "drop table if exists test_cast_to_largeint_from_datetimev2_0_part6_6_not_nullable;"
    sql "create table test_cast_to_largeint_from_datetimev2_0_part6_6_not_nullable(f1 int, f2 datetimev2(0)) properties('replication_num'='1');"
    sql """insert into test_cast_to_largeint_from_datetimev2_0_part6_6_not_nullable values (0, "0100-12-01 01:01:00"),(1, "0100-12-01 01:01:00"),(2, "0100-12-01 01:01:00"),(3, "0100-12-01 01:01:01"),(4, "0100-12-01 01:01:01"),(5, "0100-12-01 01:01:01"),(6, "0100-12-01 01:01:59"),(7, "0100-12-01 01:01:59"),(8, "0100-12-01 01:01:59"),(9, "0100-12-01 01:59:00"),(10, "0100-12-01 01:59:00"),(11, "0100-12-01 01:59:00"),(12, "0100-12-01 01:59:01"),(13, "0100-12-01 01:59:01"),(14, "0100-12-01 01:59:01"),(15, "0100-12-01 01:59:59"),(16, "0100-12-01 01:59:59"),(17, "0100-12-01 01:59:59"),(18, "0100-12-01 23:00:00"),(19, "0100-12-01 23:00:00"),
      (20, "0100-12-01 23:00:00"),(21, "0100-12-01 23:00:01"),(22, "0100-12-01 23:00:01"),(23, "0100-12-01 23:00:01"),(24, "0100-12-01 23:00:59"),(25, "0100-12-01 23:00:59"),(26, "0100-12-01 23:00:59"),(27, "0100-12-01 23:01:00"),(28, "0100-12-01 23:01:00"),(29, "0100-12-01 23:01:00"),(30, "0100-12-01 23:01:01"),(31, "0100-12-01 23:01:01"),(32, "0100-12-01 23:01:01"),(33, "0100-12-01 23:01:59"),(34, "0100-12-01 23:01:59"),(35, "0100-12-01 23:01:59"),(36, "0100-12-01 23:59:00"),(37, "0100-12-01 23:59:00"),(38, "0100-12-01 23:59:00"),(39, "0100-12-01 23:59:01"),
      (40, "0100-12-01 23:59:01"),(41, "0100-12-01 23:59:01"),(42, "0100-12-01 23:59:59"),(43, "0100-12-01 23:59:59"),(44, "0100-12-01 23:59:59"),(45, "0100-12-28 00:00:00"),(46, "0100-12-28 00:00:00"),(47, "0100-12-28 00:00:00"),(48, "0100-12-28 00:00:01"),(49, "0100-12-28 00:00:01"),(50, "0100-12-28 00:00:01"),(51, "0100-12-28 00:00:59"),(52, "0100-12-28 00:00:59"),(53, "0100-12-28 00:00:59"),(54, "0100-12-28 00:01:00"),(55, "0100-12-28 00:01:00"),(56, "0100-12-28 00:01:00"),(57, "0100-12-28 00:01:01"),(58, "0100-12-28 00:01:01"),(59, "0100-12-28 00:01:01"),
      (60, "0100-12-28 00:01:59"),(61, "0100-12-28 00:01:59"),(62, "0100-12-28 00:01:59"),(63, "0100-12-28 00:59:00"),(64, "0100-12-28 00:59:00"),(65, "0100-12-28 00:59:00"),(66, "0100-12-28 00:59:01"),(67, "0100-12-28 00:59:01"),(68, "0100-12-28 00:59:01"),(69, "0100-12-28 00:59:59"),(70, "0100-12-28 00:59:59"),(71, "0100-12-28 00:59:59"),(72, "0100-12-28 01:00:00"),(73, "0100-12-28 01:00:00"),(74, "0100-12-28 01:00:00"),(75, "0100-12-28 01:00:01"),(76, "0100-12-28 01:00:01"),(77, "0100-12-28 01:00:01"),(78, "0100-12-28 01:00:59"),(79, "0100-12-28 01:00:59"),
      (80, "0100-12-28 01:00:59"),(81, "0100-12-28 01:01:00"),(82, "0100-12-28 01:01:00"),(83, "0100-12-28 01:01:00"),(84, "0100-12-28 01:01:01"),(85, "0100-12-28 01:01:01"),(86, "0100-12-28 01:01:01"),(87, "0100-12-28 01:01:59"),(88, "0100-12-28 01:01:59"),(89, "0100-12-28 01:01:59"),(90, "0100-12-28 01:59:00"),(91, "0100-12-28 01:59:00"),(92, "0100-12-28 01:59:00"),(93, "0100-12-28 01:59:01"),(94, "0100-12-28 01:59:01"),(95, "0100-12-28 01:59:01"),(96, "0100-12-28 01:59:59"),(97, "0100-12-28 01:59:59"),(98, "0100-12-28 01:59:59"),(99, "0100-12-28 23:00:00"),
      (100, "0100-12-28 23:00:00"),(101, "0100-12-28 23:00:00"),(102, "0100-12-28 23:00:01"),(103, "0100-12-28 23:00:01"),(104, "0100-12-28 23:00:01"),(105, "0100-12-28 23:00:59"),(106, "0100-12-28 23:00:59"),(107, "0100-12-28 23:00:59"),(108, "0100-12-28 23:01:00"),(109, "0100-12-28 23:01:00"),(110, "0100-12-28 23:01:00"),(111, "0100-12-28 23:01:01"),(112, "0100-12-28 23:01:01"),(113, "0100-12-28 23:01:01"),(114, "0100-12-28 23:01:59"),(115, "0100-12-28 23:01:59"),(116, "0100-12-28 23:01:59"),(117, "0100-12-28 23:59:00"),(118, "0100-12-28 23:59:00"),(119, "0100-12-28 23:59:00"),
      (120, "0100-12-28 23:59:01"),(121, "0100-12-28 23:59:01"),(122, "0100-12-28 23:59:01"),(123, "0100-12-28 23:59:59"),(124, "0100-12-28 23:59:59"),(125, "0100-12-28 23:59:59"),(126, "2025-01-01 00:00:00"),(127, "2025-01-01 00:00:00"),(128, "2025-01-01 00:00:00"),(129, "2025-01-01 00:00:01"),(130, "2025-01-01 00:00:01"),(131, "2025-01-01 00:00:01"),(132, "2025-01-01 00:00:59"),(133, "2025-01-01 00:00:59"),(134, "2025-01-01 00:00:59"),(135, "2025-01-01 00:01:00"),(136, "2025-01-01 00:01:00"),(137, "2025-01-01 00:01:00"),(138, "2025-01-01 00:01:01"),(139, "2025-01-01 00:01:01"),
      (140, "2025-01-01 00:01:01"),(141, "2025-01-01 00:01:59"),(142, "2025-01-01 00:01:59"),(143, "2025-01-01 00:01:59"),(144, "2025-01-01 00:59:00"),(145, "2025-01-01 00:59:00"),(146, "2025-01-01 00:59:00"),(147, "2025-01-01 00:59:01"),(148, "2025-01-01 00:59:01"),(149, "2025-01-01 00:59:01"),(150, "2025-01-01 00:59:59"),(151, "2025-01-01 00:59:59"),(152, "2025-01-01 00:59:59"),(153, "2025-01-01 01:00:00"),(154, "2025-01-01 01:00:00"),(155, "2025-01-01 01:00:00"),(156, "2025-01-01 01:00:01"),(157, "2025-01-01 01:00:01"),(158, "2025-01-01 01:00:01"),(159, "2025-01-01 01:00:59"),
      (160, "2025-01-01 01:00:59"),(161, "2025-01-01 01:00:59"),(162, "2025-01-01 01:01:00"),(163, "2025-01-01 01:01:00"),(164, "2025-01-01 01:01:00"),(165, "2025-01-01 01:01:01"),(166, "2025-01-01 01:01:01"),(167, "2025-01-01 01:01:01"),(168, "2025-01-01 01:01:59"),(169, "2025-01-01 01:01:59"),(170, "2025-01-01 01:01:59"),(171, "2025-01-01 01:59:00"),(172, "2025-01-01 01:59:00"),(173, "2025-01-01 01:59:00"),(174, "2025-01-01 01:59:01"),(175, "2025-01-01 01:59:01"),(176, "2025-01-01 01:59:01"),(177, "2025-01-01 01:59:59"),(178, "2025-01-01 01:59:59"),(179, "2025-01-01 01:59:59"),
      (180, "2025-01-01 23:00:00"),(181, "2025-01-01 23:00:00"),(182, "2025-01-01 23:00:00"),(183, "2025-01-01 23:00:01"),(184, "2025-01-01 23:00:01"),(185, "2025-01-01 23:00:01"),(186, "2025-01-01 23:00:59"),(187, "2025-01-01 23:00:59"),(188, "2025-01-01 23:00:59"),(189, "2025-01-01 23:01:00"),(190, "2025-01-01 23:01:00"),(191, "2025-01-01 23:01:00"),(192, "2025-01-01 23:01:01"),(193, "2025-01-01 23:01:01"),(194, "2025-01-01 23:01:01");
    """

    sql "set enable_strict_cast=true;"
    qt_sql_6_strict 'select f1, cast(f2 as largeint) from test_cast_to_largeint_from_datetimev2_0_part6_6_not_nullable order by 1;'

    sql "set enable_strict_cast=false;"
    qt_sql_6_non_strict 'select f1, cast(f2 as largeint) from test_cast_to_largeint_from_datetimev2_0_part6_6_not_nullable order by 1;'

}